package com.dlc.garbagerecyclebox.log;


import com.dlc.commonbiz.base.DlcLogger;
import com.dlc.commonbiz.base.util.BaseLog;
import com.dlc.commonbiz.base.util.CommonUtil;

/**
 * @author :      fangbingran
 * @aescription : todo(这里用一句话描述这个类的作用)
 * @date :        2019/07/27  16:57
 */
public class GarbageRecycleBoxLogFactory {
    private static DlcLogger mSerialPortLogger;
    private static final String SERIAL_PORT_LOG_TAG = GarbageRecycleBoxLogFactory.class.getSimpleName();

    public GarbageRecycleBoxLogFactory() {
    }

    public static void createLogger(DlcLogger serialPortLogger) {
        mSerialPortLogger = serialPortLogger;
    }

    public static void debug(String logger) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.debug(logger);
        } else {
            BaseLog.print(logger);
        }

    }

    public static void info(String logger) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.info(logger);
        } else {
            BaseLog.print(logger);
        }

    }

    public static void warn(String logger) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.warn(logger);
        } else {
            BaseLog.print(logger);
        }

    }

    public static void warn(String logger, Throwable throwable) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.warn(logger, CommonUtil.getThrowableStrRep(throwable), throwable);
        } else {
            BaseLog.print(logger);
        }

    }

    public static void error(String logger) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.error(logger);
        } else {
            BaseLog.print(logger);
        }

    }

    public static void error(String logger, Throwable throwable) {
        if (mSerialPortLogger != null) {
            mSerialPortLogger.error(logger, CommonUtil.getThrowableStrRep(throwable), throwable);
        } else {
            BaseLog.print(logger);
        }

    }
}
